import Player from "xgplayer"
import Mp4Plugin from "xgplayer-mp4"
import "xgplayer/dist/index.min.css"
import {IPlayerOptions} from "xgplayer/es/player";

export function XgplayerUtils(options: IPlayerOptions): Player {
  let defaultOptions: IPlayerOptions = {
    plugins: [Mp4Plugin],
    defaultPlaybackRate: 8,
    playbackrate: [1, 2, 3, 4, 5],
    mp4plugin: {
      maxBufferLength: 30,
      minBufferLength: 10,
      reqOptions:{
        mode: 'cors',
        method: 'GET',
        headers: { // 需要带的自定义请求头
        },
      }
    }
  }
  const player = new Player(Object.assign({}, defaultOptions, options))
  return player
}































